﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace CustomControls.SearchResult
{
    /// <summary>
    /// Interaction logic for ShopResultItem.xaml
    /// </summary>
    public partial class ShopResultItem : UserControl
    {
        #region Dependency Properties
        public int ShopId
        {
            get { return (int)GetValue(ShopIdProperty); }
            set { SetValue(ShopIdProperty, value); }
        }

        public static readonly DependencyProperty ShopIdProperty =
            DependencyProperty.Register("ShopId", typeof(int), typeof(ShopResultItem), new UIPropertyMetadata(0));


        public string Title
        {
            get { return (string)GetValue(TitleProperty); }
            set { SetValue(TitleProperty, value); }
        }

        public static readonly DependencyProperty TitleProperty =
            DependencyProperty.Register("Title", typeof(string), typeof(ShopResultItem), new UIPropertyMetadata(string.Empty));

        public string Details
        {
            get { return (string)GetValue(DetailsProperty); }
            set { SetValue(DetailsProperty, value); }
        }

        public static readonly DependencyProperty DetailsProperty =
            DependencyProperty.Register("Details", typeof(string), typeof(ShopResultItem), new UIPropertyMetadata(string.Empty));

        public string ShopNumber
        {
            get { return (string)GetValue(ShopNumberProperty); }
            set { SetValue(ShopNumberProperty, value); }
        }

        public static readonly DependencyProperty ShopNumberProperty =
            DependencyProperty.Register("ShopNumber", typeof(string), typeof(ShopResultItem), new UIPropertyMetadata(string.Empty));

        public string Floor
        {
            get { return (string)GetValue(FloorProperty); }
            set { SetValue(FloorProperty, value); }
        }

        public static readonly DependencyProperty FloorProperty =
            DependencyProperty.Register("Floor", typeof(string), typeof(ShopResultItem), new UIPropertyMetadata(string.Empty));

        public string CategoryName
        {
            get { return (string)GetValue(CategoryNameProperty); }
            set { SetValue(CategoryNameProperty, value); }
        }

        public static readonly DependencyProperty CategoryNameProperty =
            DependencyProperty.Register("CategoryName", typeof(string), typeof(ShopResultItem), new UIPropertyMetadata(string.Empty));


        #endregion

        #region Public Properties
        public event EventHandler Selected;
        public Button ShopButton
        {
            get
            {
                return shopButton;
            }
        }
        #endregion

        public ShopResultItem(int shopId, string title,string details,string shopNumber,string floor,string categoryName)
        {
            InitializeComponent();
            DataContext = this;
            ShopId = shopId;
            Title = title;
            Details = details;
            ShopNumber = shopNumber;
            Floor = floor;
            CategoryName = categoryName;
            ShopButton.Click += ShopButton_Click;
        }

        void ShopButton_Click(object sender, RoutedEventArgs e)
        {
            if(Selected!=null)
                Selected(this,new EventArgs());
        }
    }
}
